import request from '@/utils/request'

export async function loadFuncTypes() {
  let ret = await request({
    url: '/bicAdmin/common/funcType',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeDataModes() {
  let ret = await request({
    url: '/bicAdmin/common/nodeDataMode',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeTypes() {
  let ret = await request({
    url: '/bicAdmin/common/nodeType',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeVueType() {
  let ret = await request({
    url: '/bicAdmin/common/nodeVueType',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function systemSelector() {
  let ret = await request({
    url: '/bicAdmin/system/loadSelector',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function useCaseSelector(systemUuid) {
  let ret = await request({
    url: '/bicAdmin/useCase/loadSelector/' + systemUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function allUseCaseSelector() {
  let ret = await request({
    url: '/bicAdmin/useCase/loadAllSelector',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeSelector(systemUuid) {
  let ret = await request({
    url: '/bicAdmin/node/loadSelector/' + systemUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function edgeSelector(systemUuid) {
  let ret = await request({
    url: '/bicAdmin/edge/loadSelector/' + systemUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function allNodeSelector() {
  let ret = await request({
    url: '/bicAdmin/node/loadAllSelector/',
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeStyleSelector(systemUuid) {
  let ret = await request({
    url: '/bicAdmin/nodeStyle/loadSelector/' + systemUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function edgeStyleSelector(systemUuid) {
  let ret = await request({
    url: '/bicAdmin/edgeStyle/loadSelector/' + systemUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export async function nodeVueSelector(systemUuid, nodeUuid) {
  let ret = await request({
    url: '/bicAdmin/nodeVue/loadSelector/' + systemUuid + '/' + nodeUuid,
    method: 'get'
  })
  if (ret.ok) {
    return ret.data.textValues;
  }
  return []
}

export function joiner(arr, join) {
  let res = ""
  if (!res && !join) {
    return res;
  }
  for (let i = 0; i < arr.length; i++) {
    res = res + arr[i] + join;
  }
  return res.substr(0, res.length - join.length)
}
